<?php
/**
 * Created by PhpStorm.
 * User: muhe0
 * Date: 2017/4/16
 * Time: 23:55
 */
namespace LDL\Twspider ;
use LDL\Twspider\C\ReentrantLock;
use Lin\Nsg\ContentListDb;
use VDB\Spider\QueueManager\InMemoryQueueManager;
use VDB\Spider\QueueManager\QueueManagerInterface;
use VDB\Spider\RequestHandler\GuzzleRequestHandler;
use VDB\Spider\Stackable;


class TwWorker extends  \Worker {
	const LOCK="lock";
    /**
     * @var Twspider
     */
	public  $spider = null ;
	public  $topSpider =null;//= array() ;
	public function run(){
		$this->spider->logger->debug("work runing,threadId ".$this->getCurrentThreadId());
   	 }

	/**
//	 * @var \ArrayAccess
	 *
	 */
	//public $data ;
    public   function  __construct($obj,$topSpider)
    {
	    $this->spider = $obj;
	   // if($metaData!=null){
        $this->topSpider = $topSpider;
           // $this->stack()
      //  }

       // var_dump($this->metaData->count().get_class($this->metaData));
	    //in php 7. cannot overvide aready Object, becase this Lock Object is shared in threaded,
	    if(empty($this->spider[TwWorker::LOCK]))
	        $this->spider[TwWorker::LOCK]= new ReentrantLock();//Arrayaccess
        if(empty($this->selbstLock))
            $this->selbstLock= new ReentrantLock();//Arrayaccess
	}

	/**
	 * @return ReentrantLock
	 */
	public function getLock(){
		return $this->spider[TwWorker::LOCK];
	}

    public function getSelbstLock(){
        return $this->selbstLock;
    }

}



